{% set pypi_name = 'stevedore' %}
{% set upstream_version = upstream_version('3.3.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Manage dynamic plugins for Python applications
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/stevedore/latest/
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('docutils') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pytest') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Python makes loading code dynamically easy, allowing you to configure
and extend your application by discovering and loading extensions
(plugins) at runtime. Many applications implement their own
library for doing this, using ``__import__`` or ``importlib``.
stevedore avoids creating yet another extension
mechanism by building on top of setuptools entry points. The code
for managing entry points tends to be repetitive, though, so stevedore
provides manager classes for implementing common patterns for using
dynamically loaded extensions.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Manage dynamic plugins for Python applications
Requires:       {{ py3('importlib-metadata') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('six') }}

%description -n {{ py2name(py_versions='py3') }}
Python makes loading code dynamically easy, allowing you to configure
and extend your application by discovering and loading extensions
(plugins) at runtime. Many applications implement their own
library for doing this, using ``__import__`` or ``importlib``.
stevedore avoids creating yet another extension
mechanism by building on top of setuptools entry points. The code
for managing entry points tends to be repetitive, though, so stevedore
provides manager classes for implementing common patterns for using
dynamically loaded extensions.

This package contains the Python 3.x module

%package -n python-stevedore-doc
Summary:        Documentation for %{name}
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}

%description -n python-stevedore-doc
Python makes loading code dynamically easy, allowing you to configure
and extend your application by discovering and loading extensions
(plugins) at runtime. Many applications implement their own
library for doing this, using ``__import__`` or ``importlib``.
stevedore avoids creating yet another extension
mechanism by building on top of setuptools entry points. The code
for managing entry points tends to be repetitive, though, so stevedore
provides manager classes for implementing common patterns for using
dynamically loaded extensions.

This package contains documentation in HTML format.

%prep
%autosetup -p1 -n {{ pypi_name }}-%{version}
%py_req_cleanup

%build
%py3_build

# generate html docs
PBR_VERSION={{ upstream_version }} PYTHONPATH=. %sphinx_build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%check
# use pytest instead of stestr to break a build cycle between python-cliff, python-stestr and python-stevedore
python3 -m pytest stevedore/tests

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/{{ pypi_name }}-*.egg-info

%files -n python-stevedore-doc
%license LICENSE
%doc doc/build/html

%changelog
